package com.kk.demo.unsface.two.unsafelist.copy;

public class User implements Comparable<User> {

    /**
    * @字段说明 id
    */
    private int id;

    /**
     * 
    * @字段说明 age
    */
    private int age;

    public User(int id, int age) {
        this.id = id;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("User [id=");
        builder.append(id);
        builder.append(", age=");
        builder.append(age);
        builder.append("]");
        return builder.toString();
    }

    @Override
    public int compareTo(User o) {
        
        if(this.age > o.age)
        {
            return 1;
        }
        
        else if(this.age < o.age)
        {
            return -1;
        }
        
        return 0;
    }

}
